<?php 

require("function/config.inc.php");
require("function/mysql.inc.php");
//-----------------------------------------
//Name : Pfsm999
//Date : 17/01/09
//Version : 0.7
//-----------------------------------------
	$id = array();
	$ida = array();
	$block = array();

	$sql = "SELECT steamid, name FROM ach_names";
	$result = mysql_query($sql);
	if (!$result) 
	{
		echo "ACH_NAME NOT FOUND";
		exit();
	}
	while ($row = mysql_fetch_assoc($result)) {
		$sql = "INSERT INTO achmw_users VALUES (\"".$row['steamid']."\",\"".addslashes($row['name'])."\");";
		mysql_query($sql);
		
		$sql = "INSERT INTO achmw_users VALUES (\"".$row['steamid']."\",\"".$row['name']."\");";
		mysql_query($sql);
		
		//echo $sql."  -  ".$resultat."<br/>";
	}
	
	$sql = "SELECT cat_id, name FROM ach_categories";
	$result = mysql_query($sql);
	if (!$result) 
	{
		echo "ACH_CATEGORIES NOT FOUND";
		exit();
	}
	while ($row = mysql_fetch_assoc($result)) {
		$sql = "INSERT INTO achmw_categories VALUES(\"".$row['cat_id']."\",\"".$row['name']."\");";
		//echo $sql."<br/>";
		mysql_query($sql);
	}
	
	//SNIPER
	$sql = "SELECT * FROM ach_server_sniper";
	$result = mysql_query($sql);
	if (!$result) 
	{
		echo "ACH_SERVER_SNIPER NOT FOUND";
		exit();
	}
	while ($row = mysql_fetch_assoc($result)) {
		if($row['jarate']==1)
		{
			if($row['jarate_attack']==1)
				$winner = 1;
			else
				$winner = 0;
			$sql = "INSERT INTO achmw_blocks_jarate VALUES (NULL,".$winner.");";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_jarate;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "jarate";
		}
		elseif($row['razor']==1)
		{
			if($row['razor_attack']==1)
				$winner = 1;
			else
				$winner = 0;
			$sql = "INSERT INTO achmw_blocks_razorback VALUES (NULL,".$winner.");";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_razorback;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "razorback";
		}
	}
	
	$sql = "SELECT * FROM ach_server_scout";
	$result = mysql_query($sql);
	if (!$result) 
	{
		echo "ACH_SERVER_SCOUT NOT FOUND";
		exit();
	}
	while ($row = mysql_fetch_assoc($result)) {
		if($row['stunt']==1)
		{
			if($row['stuntattack']==1)
				$winner = 1;
			else
				$winner = 0;
			$sql = "INSERT INTO achmw_blocks_stunner VALUES (NULL,".$winner.");";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_stunner;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "stunner";
		}
	}
	
	$sql = "SELECT * FROM ach_server_medic";
	$result = mysql_query($sql);
	if (!$result) 
	{
		echo "ACH_SERVER_MEDIC NOT FOUND";
		exit();
	}
	while ($row = mysql_fetch_assoc($result)) {
		$winner = 0;
		$sql = "INSERT INTO achmw_blocks_ubercharge VALUES (NULL,".$winner.",\"".$row['weapons']."\");";
		//echo $sql."<br/>";
		mysql_query($sql);
		$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_ubercharge;";
		$max = mysql_query($sql);
		$max2 = mysql_fetch_assoc($max);
		//echo $row['ida'];
		$ida[] = $row['ida'];
		$id[] = $max2['MaxId'];
		$block[] = "ubercharge";
	}
	
	$sql = "SELECT * FROM ach_server_heavy";
	$result = mysql_query($sql);
	if (!$result) 
	{
		echo "ACH_SERVER_HEAVY NOT FOUND";
		exit();
	}
	while ($row = mysql_fetch_assoc($result)) {
		if($row['own']==1)
		{
			$sql = "INSERT INTO achmw_blocks_eatsandwich VALUES (NULL);";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_eatsandwich;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "eatsandwich";
		}
		elseif($row['notown']==1)
		{
			if($row['notown_target']==1)
				$winner = 1;
			else
				$winner = 0;
			$sql = "INSERT INTO achmw_blocks_stealsandwich VALUES (NULL,".$winner.");";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_eatsandwich;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "stealsandwich";
		}
	}
	
	$sql = "SELECT * FROM ach_server_fun";
	$result = mysql_query($sql);
	if (!$result) 
	{
		echo "ACH_SERVER_FUN NOT FOUND";
		exit();
	}
	while ($row = mysql_fetch_assoc($result)) {
		if($row['callmedic']!=0)
		{
			$sql = "INSERT INTO achmw_blocks_callmedic VALUES (NULL);";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_callmedic;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "callmedic";
		}
		elseif($row['say']!="")
		{
			$sql = "INSERT INTO achmw_blocks_say VALUES (NULL,0,\"".$row['say']."\",\"\");";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_say;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "say";
		}
	}
	
	$sql = "SELECT * FROM ach_server_engineer";
	$result = mysql_query($sql);
	if (!$result) 
	{
		echo "ACH_SERVER_ENGINEER NOT FOUND";
		exit();
	}
	while ($row = mysql_fetch_assoc($result)) {
		if($row['construction']!=0)
		{
			if($row['sentry']!=0)
			{
				$construction = 3;
			}
			elseif($row['dispenser']!=0)
			{
				$construction = 0;
			}
			elseif($row['teleporterentry']!=0)
			{
				$construction = 1;
			}
			elseif($row['teleporterexit']!=0)
			{
				$construction = 2;
			}
			$sql = "INSERT INTO achmw_blocks_engineer_pda VALUES (NULL,0,".$construction.");";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_engineer_pda;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "engineer_pda";
		}
		if($row['teleport']!=0)
		{
			if($row['teleport_build']==1)
				$winner = 0;
			else
				$winner = 1;
			$sql = "INSERT INTO achmw_blocks_engineer_teleport VALUES (NULL,".$winner.",\"\",\"\",\"\",0);";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_engineer_teleport;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "engineer_teleport";
		}
		if($row['destruction']!=0)
		{
			if($row['sentry']!=0)
			{
				$destruction = 3;
			}
			elseif($row['dispenser']!=0)
			{
				$destruction = 0;
			}
			elseif($row['teleporterentry']!=0)
			{
				$destruction = 1;
			}
			elseif($row['teleporterexit']!=0)
			{
				$destruction = 2;
			}
			
			if($row['des_vic']==1)
				$winner = 0;
			else
				$winner = 1;
				
			$sql = "INSERT INTO achmw_blocks_kill VALUES (NULL,".$winner.",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",-1,-1,-1,-1,-1,-1,-1,".$destruction.",".$row['was_build'].");";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_kill;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "kill";
		}
	}
	
	
	$sql = "SELECT * FROM ach_server";
	$result = mysql_query($sql);
	if (!$result) 
	{
		echo "ACH_SERVER NOT FOUND";
		exit();
	}
	while ($row = mysql_fetch_assoc($result)) {
	
		if($row['victim']!=0)
		{
			$winner = 0;
		}
		elseif($row['attacker']!=0)
		{
			$winner = 1;
		}
		elseif($row['assist']!=0)
		{
			$winner = 2;
		}
		$victimSteamID = "";
		if($row['victimSteamID']!="any")
		{
			$victimSteamID = $row['victimSteamID'];
		}
		$attackerSteamID = "";
		if($row['attackerSteamID']!="any")
		{
			$attackerSteamID = $row['attackerSteamID'];
		}
		$assistSteamID = "";
		if($row['assistSteamID']!="any")
		{
			$assistSteamID = $row['assistSteamID'];
		}
		$weapon = "";
		if($row['weapon']!="any")
		{
			$weapon = $row['weapon'];
		}
		$map = "";
		if($row['map']!="any")
		{
			$map = $row['map'];
		}
		
		$domination = $row['domination'];
		$revenge = $row['revenge'];
		$headshot = $row['headshot'];
		$backstab = $row['backstab'];
		$deadringer = $row['deadringer'];
		$class = "";
		if($row['class']!="any")
		{
			$class = $row['class'];
		}
		$class2 ="";
		if($row['class2']!="any")
		{
			$class2 = $row['class2'];
		}
		
		if($row['crits']==0)
		{
			$crits = -1;
		}
		else
		{
			$crits = $row['crits'];
		}
		
		if($row['suicide']!=0)
		{
			$suicide = 1;
		}
		else
		{
			$suicide = 0;
		}
		
		$sql = "INSERT INTO achmw_blocks_kill VALUES (NULL,".$winner.",\"".$attackerSteamID."\",\"".$victimSteamID."\",\"".$assistSteamID."\",\"".$weapon."\",\"".$map."\",\"".$class."\",\"".$class2."\",\"\",".$suicide.",".$crits.",".$domination.",".$revenge.",".$headshot.",".$backstab.",".$deadringer.",-1,-1);";
		//echo $sql."<br/>";
		mysql_query($sql);
		$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_kill;";
		$max = mysql_query($sql);
		$max2 = mysql_fetch_assoc($max);
		$ida[] = $row['ida'];
		$id[] = $max2['MaxId'];
		$block[] = "kill";
		
		if($row['hpmoinsplusegal']!=0 && $row['hpmoinsplusegal']!=-1)
		{
			echo "oui";
			$type = 1;
			$sql = "INSERT INTO achmw_blocks_condition VALUES (NULL,".$type.",1,".$row['hptext'].",".$row['hptext2'].",0);";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_condition;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "condition";
		}
		if($row['distancemoinsplusegal']!=0 && $row['distancemoinsplusegal']!=-1)
		{
			$type = 2;
			$sql = "INSERT INTO achmw_blocks_condition VALUES (NULL,".$type.",1,".$row['distancemoins'].",".$row['distanceplus'].",0);";
			//echo $sql."<br/>";
			mysql_query($sql);
			$sql = "SELECT MAX(id) As MaxId FROM achmw_blocks_condition;";
			$max = mysql_query($sql);
			$max2 = mysql_fetch_assoc($max);
			$ida[] = $row['ida'];
			$id[] = $max2['MaxId'];
			$block[] = "condition";
		}
	}
	
	
	//----END -------
	$sql = "SELECT * FROM ach_config";
	$result = mysql_query($sql);
	if (!$result) 
	{
		echo "ACH_CONFIG NOT FOUND";
		exit();
	}
	while ($row = mysql_fetch_assoc($result)) {
		
		$nameOfAchiev =  $row['name'];
		$descriptionOfAchiev =  $row['description'];
		$imageOfAchiev =  $row['image'];
		$amountOfAchiev =  $row['amount'];
		$catOfAchiev =  $row['cat_id'];
		$idOfachiev = $row['id'];
		
		$j=-1;
		for($i=0; $i<count($ida);$i++)
		{
			if($ida[$i] == $idOfachiev)
			{
				//echo $ida[$i]." == ".$idOfachiev."<br/>".$i."<br/>";
				$j = $i;
				$i = count($ida) + 1;
			}
		}
		if($j != -1)
		{
			$f = $j + 1;
			$passoupas = true;
			//echo $j." - ".$block[$j]."<br/>";
			//echo $f." - ".$block[$f]."<br/>";
			if($block[$f] == "condition")
			{
				//echo "oui1";
				$g = $f + 1;
				if($block[$g] == "condition")
				{
					echo "oui2";	
					$sql = "INSERT INTO achmw_achievements VALUES (NULL,\"".$nameOfAchiev."\",\"".$descriptionOfAchiev."\",".$amountOfAchiev.",\"".$imageOfAchiev."\",".$catOfAchiev.",0,0,-1,\"".$block[$j]."\",".$id[$j].",1,\"".$block[$f]."\",".$id[$f].",1,\"".$block[$g]."\",".$id[$g].",1,\"none\",-1,1,\"none\",-1,1);";
					mysql_query($sql);
					$sql = "SELECT MAX(id) As MaxId FROM achmw_achievements;";
					$max = mysql_query($sql);
					$max2 = mysql_fetch_assoc($max);
					$achid[$ida[$j]] = $max2['MaxId'];
					$amountid[$ida[$j]] = $amountOfAchiev;
				}
				else
				{
					//echo "non2";
					$sql = "INSERT INTO achmw_achievements VALUES (NULL,\"".$nameOfAchiev."\",\"".$descriptionOfAchiev."\",".$amountOfAchiev.",\"".$imageOfAchiev."\",".$catOfAchiev.",0,0,-1,\"".$block[$j]."\",".$id[$j].",1,\"".$block[$f]."\",".$id[$f].",1,\"none\",-1,1,\"none\",-1,1,\"none\",-1,1);";
					mysql_query($sql);
					$sql = "SELECT MAX(id) As MaxId FROM achmw_achievements;";
					$max = mysql_query($sql);
					$max2 = mysql_fetch_assoc($max);
					$achid[$ida[$j]] = $max2['MaxId'];
					$amountid[$ida[$j]] = $amountOfAchiev;
				}
				$passoupas = false;
			}
			
			if($passoupas)
			{
				$sql = "INSERT INTO achmw_achievements VALUES (NULL,\"".$nameOfAchiev."\",\"".$descriptionOfAchiev."\",".$amountOfAchiev.",\"".$imageOfAchiev."\",".$catOfAchiev.",0,0,-1,\"".$block[$j]."\",".$id[$j].",1,\"none\",-1,1,\"none\",-1,1,\"none\",-1,1,\"none\",-1,1);";
				mysql_query($sql);
				$sql = "SELECT MAX(id) As MaxId FROM achmw_achievements;";
				$max = mysql_query($sql);
				$max2 = mysql_fetch_assoc($max);
				$achid[$ida[$j]] = $max2['MaxId'];
				$amountid[$ida[$j]] = $amountOfAchiev;
			}
		}
	}
	
		//echo $ida[$j]." == ".$idOfachiev."<br/>";
		//echo $j."<br/>";
		/*echo "<pre>";
		print_r($block);
		echo "</pre><br/>";*/
		/*echo "<pre>";
		print_r($ida);
		echo "</pre>";*/
	
	for($i=0;$i<count($ida);$i++)
	{
		$sql = "SELECT * FROM ach_users WHERE aid = ".$ida[$i];
		$result = mysql_query($sql);
		while ($row = mysql_fetch_assoc($result)) {
			$steamidOfMan  =  $row['steamid'];
			$intervalOfMan =  $row['interval'];
			$sql = "INSERT INTO achmw_users_blocks VALUES ('".$steamidOfMan."_".$block[$i]."_".$id[$i]."','".$steamidOfMan."','".$block[$i]."',".$id[$i].",".$intervalOfMan.");";
			//echo $sql."<br/>";
			mysql_query($sql);
			if($amountid[$ida[$i]] == $intervalOfMan)
			{
				$sql = "INSERT INTO achmw_users_ach VALUES ('".$steamidOfMan."_".$achid[$ida[$i]]."','".$steamidOfMan."',".$achid[$ida[$i]].",".$intervalOfMan.",1);";
				//echo $sql."<br/>";
				mysql_query($sql);
			}
			else
			{
				$sql = "INSERT INTO achmw_users_ach VALUES ('".$steamidOfMan."_".$achid[$ida[$i]]."','".$steamidOfMan."',".$achid[$ida[$i]].",".$intervalOfMan.",0);";
				//echo $sql."<br/>";
				mysql_query($sql);
			}
		}
	}
?>
DONE, Don't forget to delete this file !
	